package com.test.chatdemo.pojo;


import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class Result<T> implements Serializable {
    //1成功 0失败
    private Integer code ;
    private Object data;
    private String msg;

    Map<String, Object> response = new HashMap<>();

    public Result() {
    }
    public Result(Integer code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }
    public Integer getCode() {

        return code;
    }
    public void setCode(Integer code) {

        this.code = code;
    }
    public Object getData() {

        return data;
    }
    public void setData(Object data) {
        this.data = data;
    }
    public String getMsg() {

        return msg;
    }
    public void setMsg(String msg) {

        this.msg = msg;
    }

    public static <T> Result<T> success(Object data){
        return new Result<T>(1, data,"成功" );
    }
    public static <T> Result<T> success(){

        return new Result<T>(1, new HashMap<>(), "成功");
    }
    public static <T> Result<T> error(String msg){

        return new Result<T>(0, null, msg);
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", data='" + data + '\'' +
                ", msg=" + msg +
                '}';
    }
}
